package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListModel;

import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaMPrima extends javax.swing.JFrame {
	private JPanel panIngrediente;
	private JButton btnSalir;
	private JTextField txtNombre;
	private JTable tblIngrediente;
	private JButton btnRegistrar;
	private JButton btnEliminar;
	private JButton btnModificar;
	private JButton btnGuardar;
	private JTextField txtCosto;
	private JLabel lblProvee;
	private JComboBox cmbTCan;
	private JButton btnAceptar;
	private JLabel lblCant;
	private JTextField txtCant;
	private JLabel lblCod;
	private JTextField txtCod;
	private JButton btnOtro;
	private JComboBox cboProveedor;
	private JComboBox cboPre;
	private JLabel lblTitulo;
	private JLabel lblCosto;
	private JLabel lblpre;
	private JLabel lblNombre;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VentanaMPrima inst = new VentanaMPrima();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VentanaMPrima() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				panIngrediente = new JPanel();
				getContentPane().add(panIngrediente, BorderLayout.CENTER);
				panIngrediente.setLayout(null);
				panIngrediente.setPreferredSize(new java.awt.Dimension(677, 261));
				panIngrediente.setBackground(new java.awt.Color(203,183,215));
				{
					btnSalir = new JButton();
					panIngrediente.add(btnSalir);
					btnSalir.setText("Salir");
					btnSalir.setBounds(638, 291, 92, 22);
				}
				{
					lblNombre = new JLabel();
					panIngrediente.add(lblNombre);
					lblNombre.setText("Nombre:");
					lblNombre.setBounds(394, 107, 60, 15);
				}
				{
					lblpre = new JLabel();
					panIngrediente.add(lblpre);
					lblpre.setText("Presentación:");
					lblpre.setBounds(395, 142, 107, 15);
				}
				{
					lblCosto = new JLabel();
					panIngrediente.add(lblCosto);
					lblCosto.setText("Costo:");
					lblCosto.setBounds(395, 182, 59, 15);
				}
				{
					lblTitulo = new JLabel();
					panIngrediente.add(lblTitulo);
					lblTitulo.setText("MATERIA PRIMA");
					lblTitulo.setBounds(288, 17, 178, 25);
					lblTitulo.setFont(new java.awt.Font("Arial",0,20));
				}
				{
					txtNombre = new JTextField();
					panIngrediente.add(txtNombre);
					txtNombre.setBounds(477, 104, 248, 22);
				}
				{
					ComboBoxModel cboPreModel = 
							new DefaultComboBoxModel(
									new String[] { "Item One", "Item Two" });
					cboPre = new JComboBox();
					panIngrediente.add(cboPre);
					cboPre.setModel(cboPreModel);
					cboPre.setBounds(496, 138, 230, 22);
				}
				{
					txtCosto = new JTextField();
					panIngrediente.add(txtCosto);
					txtCosto.setBounds(478, 179, 104, 22);
				}
				{
					btnGuardar = new JButton();
					panIngrediente.add(btnGuardar);
					btnGuardar.setText("Guardar");
					btnGuardar.setBounds(524, 291, 97, 22);
				}
				{
					btnModificar = new JButton();
					panIngrediente.add(btnModificar);
					btnModificar.setText("Modificar");
					btnModificar.setBounds(138, 291, 114, 22);
				}
				{
					btnEliminar = new JButton();
					panIngrediente.add(btnEliminar);
					btnEliminar.setText("Eliminar");
					btnEliminar.setBounds(257, 291, 114, 22);
				}
				{
					btnRegistrar = new JButton();
					panIngrediente.add(btnRegistrar);
					btnRegistrar.setText("Registrar");
					btnRegistrar.setBounds(19, 291, 114, 22);
				}
				{
					DefaultTableModel tblIngredienteModel = 
							new DefaultTableModel(
									new String[][] {},
									new String[] { "Codigo", "Nombre" });
					tblIngrediente = new JTable();
					panIngrediente.add(tblIngrediente);
					tblIngrediente.setModel(tblIngredienteModel);
					tblIngrediente.setBounds(18, 70, 352, 188);
				}
				{
					lblProvee = new JLabel();
					panIngrediente.add(lblProvee);
					lblProvee.setText("Proveedor:");
					lblProvee.setBounds(395, 251, 80, 15);
				}
				{
					ComboBoxModel cboProveedorModel = 
							new DefaultComboBoxModel(
									new String[] { "Item One", "Item Two" });
					cboProveedor = new JComboBox();
					panIngrediente.add(cboProveedor);
					cboProveedor.setModel(cboProveedorModel);
					cboProveedor.setBounds(478, 247, 179, 22);
				}
				{
					btnOtro = new JButton();
					panIngrediente.add(btnOtro);
					btnOtro.setText("Otro");
					btnOtro.setBounds(663, 247, 67, 23);
				}
				{
					txtCod = new JTextField();
					panIngrediente.add(txtCod);
					txtCod.setBounds(477, 70, 111, 22);
				}
				{
					lblCod = new JLabel();
					panIngrediente.add(lblCod);
					lblCod.setText("Codigo:");
					lblCod.setBounds(394, 73, 60, 15);
				}
				{
					txtCant = new JTextField();
					panIngrediente.add(txtCant);
					txtCant.setBounds(478, 213, 54, 22);
				}
				{
					lblCant = new JLabel();
					panIngrediente.add(lblCant);
					lblCant.setText("Cantidad:");
					lblCant.setBounds(395, 216, 71, 15);
				}
				{
					ComboBoxModel cmbTCanModel = 
							new DefaultComboBoxModel(
									new String[] { "ml", "gr" });
					cmbTCan = new JComboBox();
					panIngrediente.add(cmbTCan);
					{
						btnAceptar = new JButton();
						panIngrediente.add(btnAceptar);
						btnAceptar.setText("Aceptar");
						btnAceptar.setBounds(520, 291, 98, 22);
					}
					cmbTCan.setModel(cmbTCanModel);
					cmbTCan.setBounds(538, 212, 45, 22);
				}
			}
			pack();
			this.setSize(747, 364);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	//SETTER Y GETTERS
	public JTextField getTxtNombre() {
		return txtNombre;
	}

	public void setTxtNombre(JTextField txtNombre) {
		this.txtNombre = txtNombre;
	}

	public JTextField getTxtCosto() {
		return txtCosto;
	}

	public void setTxtCosto(JTextField txtCosto) {
		this.txtCosto = txtCosto;
	}

	public JComboBox getCboProveedor() {
		return cboProveedor;
	}

	public void setCboProveedor(JComboBox cboProveedor) {
		this.cboProveedor = cboProveedor;
	}

	public JComboBox getCboPre() {
		return cboPre;
	}

	public void setCboPre(JComboBox cboPre) {
		this.cboPre = cboPre;
	}
	
	public JComboBox getCmbTCan() {
		return cmbTCan;
	}

	public void setCmbTCan(JComboBox cmbTCan) {
		this.cmbTCan = cmbTCan;
	}

	public JTextField getTxtCant() {
		return txtCant;
	}

	public void setTxtCant(JTextField txtCant) {
		this.txtCant = txtCant;
	}

	//LISTENERS
	public void agregarListener(ActionListener action){
		btnSalir.addActionListener(action);
		btnGuardar.addActionListener(action);
		btnModificar.addActionListener(action);
		btnEliminar.addActionListener(action);
		btnRegistrar.addActionListener(action);
		btnOtro.addActionListener(action);
		btnAceptar.addActionListener(action);
	}
	
	//DESABILITAR DE BOTONES
	public void bloquearBtnGuardar(boolean valor){
		btnGuardar.setEnabled(valor);
	}
	
	public void bloquearBtnOtro(boolean valor){
		btnOtro.setEnabled(valor);
	}
	
	//DESABILITAR DE COMBOS
	public void bloquearCboPre(boolean valor){
		cboPre.setEnabled(valor);
	}
	
	public void bloquearCboPro(boolean valor){
		cboProveedor.setEnabled(valor);
	}
	
	public void bloquearCboTCant (boolean valor){
		cmbTCan.setEnabled(valor);
	}
	
	
	//DESABILITAR TXT
	public void bloquearNombre(boolean valor){
		txtNombre.setEditable(valor);
	}
	
	public void bloquearCod(boolean valor){
		txtCod.setEditable(valor);
	}
	
	public void bloquearCosto(boolean valor){
		txtCosto.setEditable(valor);
	}
	
	public void bloquearCant(boolean valor){
		txtCant.setEditable(valor);
	}
	
	//VISIBILIDAD BOTONES
	public void visibleAceptar(boolean valor){
		btnAceptar.setVisible(valor);
	}
	
	public void visibleGuardar(boolean valor){
		btnGuardar.setVisible(valor);
	}
	
	//METODO MOSTRAR MENSAJE
	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	
}
